package com.wuzuqing.android.eightdiagrams.term;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class SolarYear {

    public int year;
    public ExactDate calendar;

    public SolarYear(int year) {
        this.year = year;
        calendar = ExactDate.fromYmd(year, 1, 1);
    }

    public static SolarYear fromYear(int y) {
        return new SolarYear(y);
    }

    public static SolarYear fromDate(ExactDate date) {
        return fromYear(date.getYear());
    }

    public int getYear() {
        return this.year;
    }

    public SolarYear next(int years) {
        ExactDate date = ExactDate.fromYmd(this.year, 1, 1);
        date.setYear(date.getYear() + years);
        return fromDate(date);
    }

    public List<SolarMonth> getMonths() {
        List<SolarMonth> l = new ArrayList<>();
        SolarMonth m = SolarMonth.fromYm(this.year, 1);
        l.add(m);
        for (int i = 1; i < 12; i++) {
            l.add(m.next(i));
        }
        return l;
    }

    @Override
    public String toString() {
        return this.getYear() + "";
    }

    public String toFullString() {
        return this.getYear() + "年";
    }
}